<template>
  <div>

    <el-dialog title="商协会审核" :visible.sync="dialogVisible" @close="closeEdit(false)" width="800px">
      <el-form :model="memberForm" ref="memberForm" label-width="120px" style="width: 90%;">

        <el-row :gutter="40">
          <el-col :span="24">
            <el-form-item 
              label="状态">
              <el-radio-group v-model="status">
                <el-radio :label="1">{{statusText}}</el-radio>
              </el-radio-group>
            </el-form-item>

            <el-form-item
              label="审核说明" 
              prop="remark"
              >
              <el-input v-model="memberForm.remark" type="textarea" :rows="3"></el-input>
            </el-form-item>

          </el-col>
        </el-row>

        

      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="closeEdit(false)">取 消</el-button>
        <SubmitButton v-if="checkYes == 1" type="primary" size="" :ref-form="()=>{return this.$refs['memberForm']}" :post-option="{url: checkPassUrl, data: memberForm, callback: checkCB }">
          通 过
        </SubmitButton>
        <SubmitButton v-if="checkYes == 0" type="primary" size="" :ref-form="()=>{return this.$refs['memberForm']}" :post-option="{url: checkFailUrl, data: memberForm, callback: checkCB }">
          不通过
        </SubmitButton>
      </div>

    </el-dialog>

  </div>
  
</template>


<script>

  import SubmitButton from '../common/SubmitButton'

  import CommonApi from '../../api/CommonApi'
  import MemberApi from '../../api/MemberApi'
  

  export default {
    components: {
      SubmitButton
    },
    data(){
      return {
        
        status: 1,
        statusText: '',

        memberForm: {
          id: '',
          remark: '',
        },

        checkPassUrl: MemberApi.URL_COMMERCE_CHECK_STATUS_PASS,
        checkFailUrl: MemberApi.URL_COMMERCE_CHECK_STATUS_FAIL,
      }
    },
    props: ['isShow', 'memberObj', 'checkYes'],
    computed: {
      dialogVisible: {
        get: function(){
          return this.isShow;  
        },
        set: function(val){}
      }
    },
    watch: {
      dialogVisible: function(newVal, oldVal){
        if (newVal) {
          this.memberForm.id = this.memberObj.id;
          if (this.checkYes == 1) {
            this.statusText = '通过';
          }else{
            this.statusText = '不通过';
          }
        }
      }
    },
    created(){
    },
    methods: {
      checkCB(json){
        this.closeEdit(true);
      },
      closeEdit(isSuccess){
        this.$refs['memberForm'].resetFields();
        this.$root.eventHub.$emit('closeEditDialog', isSuccess);
      }
    }
  }
</script>

